package com.fengye.algorithms.leecode;

/**
 * @Author fengye
 * @Date 2023/4/8 11:56
 **/
public class MoveZeroes283 {
    public void moveZeroes(int[] nums) {
        if(nums.length == 1) {
            return;
        }

        for(int i=0,j=i+1;i<j&&j<nums.length;) {
            if(nums[i] == 0) {
                if(nums[j] != 0) {
                    nums[i] = nums[j];
                    nums[j] = 0;
                    i++;
                    j++;
                } else {
                    j++;
                }
            } else {
                i++;
                j++;
            }
        }
    }
}
